const express = require('express');
const router = express.Router();
const ProductController = require('../controllers/productController');
const authMiddleware = require('../middlewares/authMiddleware');
const upload = require('../middlewares/uploadMiddleware');

// 获取所有商品
router.get('/', ProductController.getAllProducts);

// 获取商品详情
router.get('/:id', ProductController.getProductById);

// 创建商品 (需要管理员权限)
router.post('/', authMiddleware, upload.single('image'), ProductController.createProduct);

// 更新商品 (需要管理员权限)
router.put('/:id', authMiddleware, upload.single('image'), ProductController.updateProduct);

// 删除商品 (需要管理员权限)
router.delete('/:id', authMiddleware, ProductController.deleteProduct);

module.exports = router;